package com.gupao.edu.study.proxy.jdk;

import com.gupao.edu.study.proxy.staticed.NoNameService;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class NoNameServiceimplHandler implements InvocationHandler{

    private NoNameService noNameService;

    public Object getInstance(NoNameService target){
        this.noNameService = target;
        Class<?> aClass = target.getClass();
        return Proxy.newProxyInstance(aClass.getClassLoader(),aClass.getInterfaces(),this);
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("就是想搞点事情");
        method.invoke(this.noNameService,args);
        return null;
    }
}
